package com.zpark.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @Author: Abigale
 * @Date: 2022/10/18 10:37
 * @Version: 1.0
 */
@Configuration
@EnableSwagger2 // 开启Swagger2注解功能
public class Swagger2Config {
    // 将方法返回的对象注入到bean里面的额，bean的ID就是方法的名字
    @Bean
    public Docket docket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
                .apis(RequestHandlerSelectors.basePackage("com.zpark.controller"))
                .paths(PathSelectors.any()).build();
    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                // 设置标题
                .title("这是文档描述标题")
                // 设置接口描述信息
                .description("这是swagger2接口文档")
                // 设置作者信息
                .contact(new Contact("yn","http://www.baidu.com","848002732@qq.com")) // url写的是get地址
                // 设置版本号
                .version("1.0")
                .build();
    }

}
